#include <bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
    int f = 0, ans = 0;
    char c = getchar();
    while (!isdigit(c))
        f |= c == '-', c = getchar();
    while (isdigit(c))
        ans = (ans << 3) + (ans << 1) + c - 48, c = getchar();
    return f ? -ans : ans;
}
void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
constexpr int N = 5e2 + 5, inf = 1e18;
int m;
inline void brute()
{
    multiset<pair<int, int>> a;
    while (m--)
    {
        char op;
        pair<int, int> p;
        cin >> op >> p.first >> p.second;
        if (op == 'A')
            a.insert(p);
        else
            a.erase(a.find(p));
        map<tuple<int, int, int>, int> f;
        auto chkmx = [&](tuple<int, int, int> i, int val)
        {
            if (get<0>(i) >= get<1>(i))
                return;
            if (f.find(i) == end(f))
                f[i] = val;
            else
                f[i] = max(f[i], val);
        };
        for (const pair<int, int> &i : a)
        {
            vector<pair<tuple<int, int, int>, int>> t;
            for (pair<const tuple<int, int, int>, int> &v : f)
                t.push_back({{max(get<0>(v.first), i.first), min(get<1>(v.first), i.second), min(get<0>(v.first), i.first)},
                             max(get<2>(v.first), i.second)});
            for (pair<tuple<int, int, int>, int> &v : t)
                chkmx(v.first, v.second);
            chkmx({i.first, i.second, i.first}, i.second);
        }
        /*
        f[i][j][k][l] -> f[i+1][]
        l=j, r=j+k-1
        max(l, first)
        min(r, second)
        */
        int ans = inf, len = inf;
        for (pair<const tuple<int, int, int>, int> &v : f)
            if (get<1>(v.first) - get<0>(v.first) < len ||
                get<1>(v.first) - get<0>(v.first) == len && v.second - get<2>(v.first) < ans)
                ans = v.second - get<2>(v.first), len = get<1>(v.first) - get<0>(v.first);
        cout << ans << '\n';
    }
}
signed main()
{
    freopen("stone.in", "r", stdin);
    freopen("stone.out", "w", stdout);
    ios::sync_with_stdio(NULL);
    cin.tie(nullptr), cout.tie(nullptr);
    cin >> m;
    if (m <= 500)
    {
        brute();
        return 0;
    }
    multiset<int> q;
    multiset<pair<pair<int, int>, int>> v;
    while (m--)
    {
        char op;
        pair<int, int> a;
        cin >> op >> a.first >> a.second;
        auto it = v.lower_bound({a, 0});
        if (op == 'A')
        {
            int res = inf;
            auto nxt = it != end(v) ? next(it) : it;
            if (nxt != end(v))
                res = nxt->second - a.first;
            if (it != begin(v))
            {
                auto pre = prev(it);
                int res = a.second - pre->first.first;
                pair<pair<int, int>, int> pr = {pre->first, res};
                q.erase(q.find(pre->second));
                v.erase(pre);
                v.insert(pr);
                q.insert(res);
            }
            v.insert({a, res});
            q.insert(res);
        }
        else
        {
            q.erase(q.find(it->second));
            auto pre = it != begin(v) ? prev(it) : it;
            auto nxt = next(it);
            if (pre != begin(v))
            {
                int res = inf;
                if (nxt != end(v))
                    res = nxt->first.second - pre->first.first;
                pair<pair<int, int>, int> pr = {pre->first, res};
                q.erase(q.find(pre->second));
                v.erase(pre);
                v.insert(pr);
                q.insert(res);
            }
            v.erase(it);
        }
        if (v.size() == 1)
            cout << begin(v)->first.second - begin(v)->first.first;
        else
            cout << *begin(q);
        cout << '\n';
    }
    return 0;
}
/*
iscanonical meanning

#9161eb
*/